Code for our ACL 2020 paper "Don't Eclipse Your Arts Due to Small Discrepancies: Boundary Repositioning with a Pointer Network for Aspect Extraction"

1）Environment：
Python：3.7.3
Tensorflow：1.14.0

2）steps to run code：
step1：Download embeddings (GloVe: http://nlp.stanford.edu/data/glove.6B.zip), save it in aspect-extraction/data1
step2：Run aspect-extraction/main.py to train and test aspect extractor

python3 main.py 

step3：After aspect extractor training and testing，then run aspect-extraction/merge-repositioning-data.py to get the training data of the boundary repositioning model, it is saved in aspect-extraction/result and named "19_repositioning_merge.json".

python3 merge-repositioning-data.py

step4: Train the boundary repositioning model in this step. First download the pre-trained model BERT(https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip), 
save it in boundary-repositioning/BERT_BASE_DIR. Copy the data aspect-extraction/result/19_repositioning_merge.json to boundary-repositioning/data_dir. After the above preparation, then run run_repositioning.py.

python3 run_repositioning.py \
  --vocab_file=$BERT_BASE_DIR/vocab.txt \
  --bert_config_file=$BERT_BASE_DIR/bert_config.json \
  --init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt \
  --do_train=True \
  --train_file=$data_dir/19_repositioning_merge.json \
  --do_predict=False \
  --predict_file=$data_dir/repositioning_test.json \
  --train_batch_size=10 \
  --learning_rate=3e-5 \
  --num_train_epochs=10 \
  --max_seq_length=360 \
  --doc_stride=128 \
  --output_dir=$repositioning_base/

step5: Test the boundary repositioning model in this step. Copy the data aspect-extraction/test_result/repositioning_test.json to boundary-repositioning/data_dir, and copy the folder aspect-extraction/test_result to boundary-repositioning/ , then run run_repositioning.py.

python3 run_repositioning.py \
  --vocab_file=$BERT_BASE_DIR/vocab.txt \
  --bert_config_file=$BERT_BASE_DIR/bert_config.json \
  --init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt \
  --do_train=False \
  --train_file=$data_dir/19_repositioning_merge.json \
  --do_predict=True \
  --predict_file=$data_dir/repositioning_test.json \
  --train_batch_size=10 \
  --learning_rate=3e-5 \
  --num_train_epochs=10 \
  --max_seq_length=360 \
  --doc_stride=128 \
  --output_dir=$repositioning_base/

step6: Run boundary-repositioning/evaluate.py, evaluate the performance of boundary repositioning model.

python3 evaluate.py
